//Fu Bingyan Bless GCH
#include<bits/stdc++.h>
using namespace std;
int n,m;
#define ll long long
int h[100100];
bool ok[100100],in[3010][3010];
ll p[100100];
struct Car{ll x,v,ac;} c[100100];
int Find_pos_over(int Lft,ll x,ll v,ll ac,ll V)
{
    int l=Lft,r=m,ans=n+1;
    while (l<=r)
    {
        int mid=(l+r)/2;
        ll pos=p[mid];
        if (v*v+2*ac*(pos-x)>V*V)
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    return ans;
}
int Find_pos_under(int Lft,ll x,ll v,ll ac,ll V)
{
    int l=Lft,r=m,ans=n+1;
    if (v*v+2*ac*(p[l]-x)<=V*V) return -1;
    while (l<=r)
    {
        int mid=(l+r)/2;
        ll pos=p[mid];
        if (v*v+2*ac*(pos-x)<=V*V)
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    return ans;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while (T--)
    {
        memset(h,0,sizeof h);
        memset(c,0,sizeof c);
        memset(ok,0,sizeof ok);
        memset(in,0,sizeof in);
        ll L,V;
        cin>>n>>m>>L>>V;
        for (int i=1;i<=n;i++)
            cin>>c[i].x>>c[i].v>>c[i].ac;
        for (int i=1;i<=m;i++)
            cin>>p[i];
        ll ans1=0;
        for (int i=1;i<=n;i++)
        {
            int Lft=lower_bound(p+1,p+m+1,c[i].x)-p;
            if (c[i].v<=V)
            {
                if (c[i].ac<=0)
                {
                    // cout<<"Never"<<endl;
                    continue;
                }
                else
                {
                    int Pos=Find_pos_over(Lft,c[i].x,c[i].v,c[i].ac,V);
                    // cout<<Pos<<' '<<m<<endl;
                    for (int j=Pos;j<=m;j++)
                    {
                        h[j]++;
                        in[j][i]=1;
                    }
                    ans1++;
                }
            }
            else
            {
                if (c[i].ac>=0)
                {
                    // cout<<"Always"<<endl;
                    for (int j=Lft;j<=m;j++)
                    {
                        h[j]++;
                        in[j][i]=1;
                    }
                    ans1++;
                }
                else
                {
                    int Rgt=Find_pos_under(Lft,c[i].x,c[i].v,c[i].ac,V)-1;
                    // cout<<Lft<<' '<<Rgt<<' '<<endl;
                    if (Lft<=Rgt)
                    {
                        for (int j=Lft;j<=Rgt;j++)
                        {
                            h[j]++;
                            in[j][i]=1;
                        }
                        ans1++;
                    }
                }
            }
        }
        cout<<ans1<<' ';
        if (ans1==0)
        {
            cout<<m<<endl;
            continue;
        }
        int tot=0,totneed=0;
        // for (int i=1;i<=m;i++)
        // {
        //     cout<<h[i]<<' ';
        //     for (int j=1;j<=n;j++)
        //         cout<<in[i][j]<<' ';
        //     cout<<endl;
        // }
        while (tot<ans1)
        {
            int ma=0,id=0;
            for (int i=1;i<=m;i++)
            {
                if (h[i]>ma)
                {
                    ma=h[i];
                    id=i;
                }
            }
            h[id]=0;
            totneed++;
            for (int i=1;i<=n;i++)
            {
                if (!in[id][i]) continue;
                for (int j=1;j<=m;j++)
                {
                    if (in[j][i])
                    {
                        h[j]--;
                        in[j][i]=0;
                    }
                }
                tot++;
            }
        }
        cout<<m-totneed<<endl;
    }
    return 0;
}